<{include file="public/member_header" /}>
<link rel="stylesheet" href="__STATIC__/assets/css/filter.min.css">
<style>
.layui-table-cell{overflow: initial!important;}
</style>
<div class="am-cf admin-main">
  <!-- sidebar start -->
  <{include file="public/member_main" /}>
  <!-- sidebar end -->
  <!-- content start -->
 <div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding am-padding-bottom-0">
       <div class="am-fl am-cf">
                <strong class="am-text-warning am-text-lg">媒体选择</strong>
            </div>
    </div>
	<hr>
	<div class="am-g">
            <div class="am-u-sm-12">
                <div class="filter" id="filter">

				<div class="filter-item filter-clear">
                       <div class="filter-label">平台：</div>
							<ul class="filter-list filter-clear" id="MediaWebNameID">
							<li class="filter-option sx active" data="0">所有</li>
								<{volist name="MediaWebNameID" id="val"}>
								<li class="filter-option sx" data="<{$val.TypeID}>"><{$val.TypeName}></li>
								<{/volist}>                    
							</ul>
						</div>
                    <div class="filter-item filter-clear">
                        <div class="filter-label">行业分类：</div>
                        <ul class="filter-list filter-clear" id="MediaIndustryID">
						 <li class="filter-option sx active" data="0">所有</li>
						<{volist name="MediaIndustryID" id="val"}>
						<li class="filter-option sx" data="<{$val.TypeID}>"><{$val.TypeName}></li>
						<{/volist}>
                      </ul>
                    </div>
                    <div class="filter-item filter-clear">
                       <div class="filter-label">地区：</div>
                        <ul class="filter-list filter-clear" id="MediaCityID">
                            <li class="filter-option sx active" data="0">所有</li>
							<{volist name="MediaCityID" id="val"}>
							<li class="filter-option sx" data="<{$val.TypeID}>"><{$val.TypeName}></li>
							<{/volist}>
						</ul>
                    </div>

                    <div class="filter-item filter-clear">
                        <div class="filter-label">链接类型：</div>
                        <ul class="filter-list filter-clear" id="MediaUrlTypeID">
                            <li class="filter-option sx active" data="0">所有</li>
							<{volist name="MediaUrlTypeID" id="val"}>
                            <li class="filter-option sx" data="<{$val.TypeID}>"><{$val.TypeName}></li>
							<{/volist}>
                         </ul>
                    </div>

                    <div class="filter-item filter-clear">
                        <div class="filter-label">发稿速度：</div>
                        <ul class="filter-list filter-clear" id="MediaSpeedID">
                            <li class="filter-option sx active" data="0">所有</li>
							<{volist name="MediaSpeedID" id="val"}>
								<li class="filter-option sx" data="<{$val.TypeID}>"><{$val.TypeName}></li>
							<{/volist}>
                        </ul>
                    </div>

                    <div class="filter-item filter-clear">
                        <div class="filter-label">新闻源：</div>
                        <ul class="filter-list filter-clear" id="MediaNewsSourceID">
                            <li class="filter-option sx active" data="0">所有</li>
							<{volist name="MediaNewsSourceID" id="val"}>
							<li class="filter-option sx" data="<{$val.TypeID}>"><{$val.TypeName}></li>
 							<{/volist}>
						</ul>
                    </div>

                    <div class="filter-item filter-clear">
                        <div class="filter-label">周末可发：</div>
						<ul class="filter-list filter-clear" id="MediaCanSendID">
                            <li class="filter-option sx active" data=0>所有</li>
							<{volist name="MediaCanSendID" id="val"}>
							<li class="filter-option sx" data="<{$val.TypeID}>"><{$val.TypeName}></li>
							<{/volist}>
                        </ul>
                    </div>

                    <div class="filter-item filter-clear">
                        <div class="filter-label">特殊行业：</div>
                        <ul class="filter-list filter-clear" id="MediaSpecialIndustryID">
                            <li class="filter-option sx active" data=0>不限</li>
							<{volist name="MediaSpecialIndustryID" id="val"}>
                            <li class="filter-option sx" data="<{$val.TypeID}>"><{$val.TypeName}></li>
							<{/volist}>
                         </ul>
                    </div>

                    <div class="filter-item filter-clear">
                        <div class="filter-label">收录情况：</div>
                        <ul class="filter-list filter-clear" id="MediaSituationID">
                            <li class="filter-option sx active" data="0">不限</li>
							<{volist name="MediaSituationID" id="val"}>
                            <li id="sltip" class="filter-option sx" data="<{$val.TypeID}>"  <{if condition="$val.TypeID eq 86"}> title="包收录的媒体,若稿件未收录,请在第二个工作日下班前提交反馈,<br>有特殊要求的媒体请按照媒体备注操作<br>(例:周五出的稿件,在周六日非正常工作日的情况下,最晚周一下班前反馈未收录)"<{/if}>><{$val.TypeName}></li>
							<{/volist}>

                        </ul>
                    </div>
					 <div class="filter-item filter-clear">
                        <div class="filter-label">入口级别：</div>
                        <ul class="filter-list filter-clear" id="MediaInLevelID">
                            <li class="filter-option sx active" data="0">不限</li>
							<{volist name="MediaInLevelID" id="val"}>
                            <li class="filter-option sx" data="<{$val.TypeID}>"><{$val.TypeName}></li>
							<{/volist}>
                        </ul>
                    </div>

					<div class="filter-item filter-clear">
                        <div class="filter-label">价格分类：</div>
                        <ul class="filter-list filter-clear" id="MediaPrice">
                            <li class="filter-option sx active" data="0">不限</li>
							<{volist name="MediaPrice" id="val"}>
                            <li class="filter-option sx" data="<{$key}>"><{$val}></li>
							<{/volist}>
                        </ul>
                    </div>
					 <div class="filter-item filter-clear">
						<div class="filter-label">节日栏目：<!--春节可发---></div>
						<ul class="filter-list filter-clear" id="yearstate">
							<li class="filter-option sx active" data="0">不限</li>
							<li class="filter-option sx" data="1" style="color: red">国庆可发<!--春节可发---><img style="vertical-align: top; margin-left: 2px;" src="__STATIC__/img/icon_new.gif"></li>
						</ul>
					</div>
					<div class="filter-item filter-clear">
                        <div class="filter-label">排序：</div>
                        <ul class="filter-list filter-clear" id="OrderWay">
							<li class="filter-option sx active" data="">默认</li>
							<li class="filter-option sx" id="priceor" data="1">价格<i class="am-icon-sort"></i></li>
							<li class="filter-option sx" id="fensior" data="2" >出稿率<i class="am-icon-sort"></i></li>
							<li class="filter-option sx" id="fensior" data="3" >电脑权重<i class="am-icon-sort"></i></li>
							<li class="filter-option sx" id="fensior" data="4" >移动权重<i class="am-icon-sort"></i></li>
						</ul>
                    </div>
                </div>
				<!--检索开始---> 
				   <div class="am-margin-bottom-xs am-margin-top"> 
					<div class="am-u-sm-6">
					<button type="button" style="margin-right: 10px;" id="status_change" class="am-btn am-btn-warning am-btn-sm">查看全部</button>		
					 <a href="<{:url('resource/add')}>" class="am-btn am-btn-primary am-btn-sm">媒体入驻</a> 
					 <button type="button" class="am-btn am-btn-secondary am-btn-sm collectlist">收藏夹</button>
					  <a href="/index/newsview/id/74.html" class="am-btn am-btn-warning am-btn-sm" target="_blank">媒体白名单</a> 
					</div> 
					<div class="am-u-md-5 am-margin-top"> 
					 <form class="am-form am-form-horizontal"> 
					  <div class="am-form-group am-margin-bottom-0"> 
					   <label class="am-form-label am-u-sm-3" for="search_media">备注：</label> 
					   <div class="am-u-sm-7 am-padding-horizontal-xs"> 
						<input name="MediaContent" id="keybz" type="text" placeholder="请输入备注" autocomplete="off" style="height: 32px" /> 
					   </div>
					   <label class="am-form-label am-u-sm-3" for="search_media">媒体：</label> 
					   <div class="am-u-sm-7 am-padding-horizontal-xs"> 
						<input name="media_name" id="keyw" type="text" placeholder="请输入媒体名称" autocomplete="off" style="height: 32px" /> 
					   </div>
					   <div class="am-u-sm-2"> 
						<button type="button" id="searchbtn" class="am-btn am-btn-sm am-btn-primary">搜索</button> 
					   </div> 
					  </div> 
					 </form> 
					</div> 
				   </div> 
				   <!--检索结束--->
				   <!--滚动公告开始--->
				   <div style="height: 1px;margin: 10px 0;border: 0;clear: both;"></div>
				   <link rel="stylesheet" type="text/css" href="__STATIC__/assets/css/jquery.smarticker.css">
					<div class="smarticker2">
						<ul>
							<{volist name="list" id="v"}>  
							<li><a href="javascript:void(0);"><{$v.NewsAbstract}></a></li>
							<{/volist}>
						</ul>
					</div>
					<script type="text/javascript" src="__STATIC__/assets/js/smarticker.js"></script>
					<!--滚动公告结束--->
            </div>
		<div class="am-g">
		  <div class="am-u-sm-12">
			<div id="my_article_wrapper" class="dataTables_wrapper no-footer">
			 <input type="hidden" id="where" value="" />
				<input type="hidden" id="collect" value="" />
				<div class="table-list table-list2" id="result" style="padding:1.5rem;">
					<table class="layui-hide" id="showing" lay-filter="showing"></table>
				</div>
			  <div class="clear"></div>
			</div>
			<div style="height: 100px;" id="heig"></div>
				<!--main-->
				<div id="yixuan" class="nextpage" style="">
					<ul id="selectedMedia" class="selectedMedia"></ul>
					<div id="checkbox"></div>
					已选媒体：<span id="yixuantr"></span>金额：
					<b><span style="color:#FF9900; font-size:16px;" id="totalmoney2">0</span></b>
					元（账户余额：<b id="money_b"><{$Money}></b> 元）
					<input value="上一步 编辑内容" onclick="location.href='<{:url('index',['temp'=>$TempArticleID])}>'" id="turnup" type="button" class="btn btn2" style="vertical-align: middle;line-height: 26px;">
					<input type="button" value=" 清 空 " onclick="clearall()" class="btn btn1" />
					<input id="submit_order" value=" 提交订单 " type="button" class="btn btn3" />
					<input name="totalmoney" type="hidden" id="totalmoney" style="border:0px;" value="0" readonly="readonly"/>
					<input type="hidden" id='yixuanhidden' name='yixuanhidden'/>
					<input type="hidden" id='TempArticleID' name='TempArticleID' value="<{$TempArticleID}>"/>
				</div>
				<form id="sb" action="<{:url('index')}>" method="POST">
				<input type="hidden" id="title" value="<{$title}>" name="title" style="width: 500px" >
				<input type="hidden" name="beizhu"  value="<{$beizhu}>" id="beizhu" style="width: 500px" >
				<input type="hidden" name="starttime"  value="<{$starttime}>" id="starttime" style="width: 500px" >
				<input type="hidden" name="article_customer"  value="<{$article_customer}>" id="article_customer" style="width: 500px" >
				<textarea id="content_desc" name="editorValue" style="height: 400px;display: none;"><{$editorValue}></textarea>
				</form>
		   </div>
		</div>

</div>
<{include file="public/member_footer" /}>
<link rel="stylesheet" href="__STATIC__/lib/layui/css/layui.css" />
<script type="text/javascript" src="__STATIC__/lib/layui/layui.js"></script>
<script>
    //展示中
    layui.use(['table','form'], function(){
        var table = layui.table,form = layui.form;
		//var documentWidth=$(document).width();
        //第一个实例
        table.render({
            elem: '#showing'
            ,url: '<{:url('/member/media/getlist')}>'
            //接口的其他参数
            ,where:{is_freeze: '0'}
            ,page: true //开启分页
            ,limit:20
            ,cols: [[ //表头
				{field:'check',  width: '40', title: '<p class="bai" data="all" id="0" onclick="checka(0)"></p>'}
				,{field: 'pdlx',align:'center', title: '频道类型', width:'100'}
                ,{field: 'MediaTitle',align:'center', title: '媒体名称', width: '195'}
                ,{field: 'price', align:'center',title: '价格', width:'80'}
                ,{field: 'cgl', align:'center',title: '出稿率', width:'80'}
                ,{field: 'dnqz',align:'center', title: '电脑权重', width: '100',templet:'#pc_weightTpl'}
                ,{field: 'ydqz',align:'center', title: '移动权重', width: '100',templet:'#m_weightTpl'}
                ,{field: 'xwy',align:'center', title: '新闻源', width: '100'}
                ,{field: 'link_type',align:'center', title: '链接情况', width: '100'}
				,{field: 'MediaContent',align:'center', title: '备注', width: '140'}
                ,{field: 'mediaid_checks',align:'center', title: '收藏', width: '80',templet:'#pc_mediagetTpl'}
            ]]
        });
    });
    //筛选
    $('#key').blur(function(){
        var key = $("#key").val();
        var where = $("#where").val();
        var arr = where.split(',');
        var id=$(this).parent().attr('id');
        var data=$(this).attr('data');
        var str = '';
        for(var i=0;i < arr.length;i++){
            if(arr[i]){
                var arr2 = arr[i].split('_');
                if(arr2[0] != id){
                    str+=arr[i]+',';
                }
            }
        }
        var string=id+'_'+data+',';
        if(id==undefined && data==undefined){
            var string='';
        }
        $("#where").val(str+''+string);
        var where = $("#where").val();
        layui.table.reload('showing', {
            url: "<{:url("media/getlist")}>",
            page:1
            //接口的其他参数
            ,where:{ where:where,media_name:key}
            //,height: 300
        });
    })
    $('.sx').click(function () {
        $(this).addClass("active").siblings().removeClass("active");
        var key = $("#key").val();
        var where = $("#where").val();
        var arr = where.split(',');
        var id=$(this).parent().attr('id');
        var data=$(this).attr('data');
		if(id === 'OrderWay'){
			var icon = $(this).children('i');
			if(icon.length === 1){
				var cName = icon[0].className;
				if(cName === 'am-icon-sort-desc' || cName === 'am-icon-sort'){
					icon[0].className = 'am-icon-sort-asc';
				   data=data;
				}else if(cName === 'am-icon-sort-asc'){
					icon[0].className = 'am-icon-sort-desc';
					data=(data+1);
				}
			}else{
			  data=(data+0);
			}
			$(this).siblings().children('i').attr("class", "am-icon-sort");
		}else{
		   data=(data);
		}
        var str = '';
        for(var i=0;i < arr.length;i++){
            if(arr[i]){
                var arr2 = arr[i].split('_');
                if(arr2[0] != id){
                    str+=arr[i]+',';
                }
            }
        }
        var string=id+'_'+data+',';
        if(id==undefined && data==undefined){
            var string='';
        }
        $("#where").val(str+''+string);
        var where = $("#where").val();
        layui.table.reload('showing', {
            url: "<{:url("media/getlist")}>",
            page:1
            //接口的其他参数
            ,where:{ where:where,key:key}
            //,height: 300
        });
    });

	    //收藏
    function CollectMedia(MediaID){
        $.ajax({
            type:"POST",
            url:"<{:url('media/collect')}>",
            data:{MediaID:MediaID},
            dataType:"json",
            cache:false,
            success:function(Result){
                if(Result.code==1){
                    layer.msg(Result.msg);
                    return false;
                }else if(Result.code==2){
                    //layer.msg(Result.msg);
                    $('.Media'+MediaID).removeClass('ClassStyle2');
                    $('.Media'+MediaID).addClass('ClassStyle1');
                    return false;
                }else{
                    //layer.msg(Result.msg);
                    //$('.Media'+MediaID).html('收藏成功');
                    $('.Media'+MediaID).removeClass('ClassStyle1');
                    $('.Media'+MediaID).addClass('ClassStyle2');
                    return false;
                }
            }
        });
    }


	//收藏夹
    $('.collectlist').click(function () {
        $('#collect').val('list');
        $(this).addClass("on").siblings().removeClass("on");
        var key = $("#keyw").val();
        var where = $("#where").val();
        var arr = where.split(',');
        var id=$(this).parent().attr('id');
        var data=$(this).attr('data');
        var str = '';
        for(var i=0;i < arr.length;i++){
            if(arr[i])
            {
                var arr2 = arr[i].split('_');
                if(arr2[0] != id){
                    str+=arr[i]+',';
                }
            }
        }
        var string=id+'_'+data+',';
        if(id==undefined && data==undefined){
            var string='';
        }
        $("#where").val(str+''+string);
        var where = $("#where").val();
        where=where.replace(/undefined/g,'');
        where=where.replace(/-,/g,'');
        layui.table.reload('showing', {
            url: "<{:url("media/getlist")}>"
            //接口的其他参数
            ,where:{ where:where,key:key,collect:'list'}
            //,height: 300
        });
    });
    //查看全部媒体
    $('#status_change').click(function () {
        $('.sx').removeClass('am-btn-secondary');
        $('.bsx').addClass('am-btn-secondary');
        $('#keyw').val('');
        $('#where').val('');
        $('#collect').val('');
        layui.table.reload('showing', {
            url: "<{:url("media/getlist")}>"
            ,where:{where:'',media_name:'',collect:''}
        });
    });
    //搜索按钮
    $("#searchbtn").click(function(data){
        var media_name=$("#keyw").val();
		var MediaContent=$("#keybz").val();
        layui.table.reload('showing', {
            url: '<{:url('media/getlist')}>'
            ,where:{media_name:media_name,MediaContent:MediaContent}
        });
    });
    //清除选择
    function clearall() {
            $(".selectedItem").each(function(){
                var id = $(this).attr('data')
				$('#'+id).prop('class','bai')
                var pic = parseFloat($(this).attr('pic'));
				$(this).remove();
      	  	});
			$(".lv").each(function(){
				$(this).prop('class','bai')
			});
        $('#totalmoney2').html(0)
    }
    //选中一种媒体
   function checka(obj) {
       var cla = $('#'+obj).attr('class')
       var data = $('#'+obj).attr('data')
	   var type ;
	   var type2 ;
       var money2 = 0;

	   // 订单总额
	   var money = parseFloat($('#totalmoney2').html());

	   // 是否选中
	   if(cla == 'bai') {
		   // 未选中
           $('#'+obj).prop('class','lv')
           type = 'bai';type2 = 'lv';
	   }else{
           $('#'+obj).prop('class','bai')
           type = 'lv'; type2 = 'bai';
	   }
	   // 是否全选
       if (data == 'all') {
           $("."+type).each(function(){
              $(this).prop('class',type2)
               var id = $(this).attr('id');
               var pic = $(this).attr('pic');
			   if(type2 == 'bai')
			   {
                   $('#d'+id).remove();
                   money2-=pic;
			   }else{
                  var mtmc = $(this).attr('name');
                  var str = '<li class="selectedItem" pic="'+pic+'"  data="'+id+'" id="d'+id+'"><span>'+mtmc+'</span><i class="delectItem" onclick="delectItem('+id+')">x</i></li>';
                   $("#selectedMedia").append(str);
                   money2+=parseFloat(pic);
              }
           });
	   }else{
	       var id = obj;
           var pic = $('#'+id).attr('pic');
		   // 是否取消选择
           if(type2 == 'bai'){
			   // 取消选择
               $('#d'+id).remove();
               money2-=pic;
           }else{
			   // 选择
               var mtmc = $('#'+id).attr('name');
               var str = '<li class="selectedItem" data="'+id+'" pic="'+pic+'" id="d'+id+'"><span>'+mtmc+'</span><i class="delectItem" onclick="delectItem('+id+')">x</i></li>';
               $("#selectedMedia").append(str);
               money2+=parseFloat(pic);
           }
	   }
       $('#totalmoney2').html(money+money2)
   }

   //删除一种媒体
    function delectItem(id) {
		// 已选中的媒体DOM
		var did = $('#d'+id);
		// 列表中的媒体DOM
		var id = $('#'+id);
		// 订单总价
        var money = parseFloat($('#totalmoney2').html());
		// 要删除的媒体价格
		var money2 = parseFloat(did.attr('pic'));
		// 修改总价
		$('#totalmoney2').html(money-money2);
		// 取消选中
        id.prop('class','bai');
		// 删除选中的媒体
		did.remove();
    }

     //提交订单
    $('#submit_order').click(function () {
        var tan = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
        $(this).attr({"disabled":"disabled"});
        var str = '';
        $(".selectedItem").each(function(){
            str += $(this).attr('data')+',';
        });
        var title = $('#title').val();
        var content_desc = $('#content_desc').val();
        var beizhu = $('#beizhu').val();
		var starttime = $('#starttime').val();
		var article_customer = $('#article_customer').val();
        var TempArticleID = $('#TempArticleID').val();
        $.ajax({
            type: "POST",
            url: "<{:url('sborder')}>",
            contentType: 'application/x-www-form-urlencoded;charset=utf-8',
            data: {str:str,title:title,editorValue:content_desc,beizhu:beizhu,starttime:starttime,article_customer:article_customer,TempArticleID:TempArticleID},
            dataType: "json",
            success: function(data){
                 layer.close(tan);
                $('#submit_order').removeAttr("disabled");
               if(data == 1)
               {
                   alert('提交成功');
                   window.location.replace("<{:url('order/index')}>");
               }else{
                   alert('发布失败');
               }
            }
        });
    });
	function update_case_link(id){
    	$.post("/member.php/media/caselinks.html",{id:id},function(res){
        	alert(res.msg);
        });
    }
	//鼠标位于 a标签上方时发生 mouseover 事件
$("#sltip").mouseover(function (e) {
	this.Mytitle = this.title;//获取超链接 title属性的内容
	this.title = ""; //设置 title属性内容为空
	$("body").append("<div id='div_toop'>" + this.Mytitle + "</div>");//将要显示的内容添加到 新建 div标签中 并追加到 body 中
$("#div_toop").css({
		//设置 div 内容位置 
		"top": (e.pageY + 10) + "px",
		"position": "absolute",//添加绝对位置
		"left": (e.pageX + 20) + "px"
	}).show("fast");// show(spe.ed,callback) speed: xian'shi'su'du
}).mouseout(function () { //鼠标指针从 a标签 上离开时 发生mouseout 事件
this.title = this.Mytitle;
$("#div_toop").remove();//移除对象
}).mousemove(function (e) { //鼠标指针在 a标签 中移动时 发生mouseout 事件
$("#div_toop").css({
		//设置 div 内容位置 
		"top": (e.pageY + 10) + "px",
		"position": "absolute",//添加绝对位置
		"left": (e.pageX + 20) + "px"
	});
});
</script>
</body>
</html>